package com.yuesystem.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yuesystem.common.R;
import com.yuesystem.entity.AcademyItem;
import com.yuesystem.service.AcademyItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/items")
@Slf4j
public class AcademyItemController {
    @Autowired
    private AcademyItemService academyItemService;

    /**
     * 根据书院id获取该书院所有条目信息
     *
     * @param id
     * @return
     */
    @GetMapping("/listAll/{id}")
    public R<List<AcademyItem>> getAll(@PathVariable Long id) {
        LambdaQueryWrapper<AcademyItem> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AcademyItem::getAcademyId, id);
        List<AcademyItem> academyItemList = academyItemService.list(queryWrapper);
        return R.success(academyItemList);
    }

}
